package com.shanghai.market.plshnaghai.model;

import com.google.gson.Gson;
import com.shanghai.market.plshnaghai.abstracts.AbstractModelPost;
import com.shanghai.market.plshnaghai.constants.UrlConstants;
import com.shanghai.market.plshnaghai.interfaces.IObjectView;
import com.shanghai.market.plshnaghai.net.HttpManager;
import com.shanghai.market.plshnaghai.publics.LogCat;

/**
 * Created by Administrator on 2017/8/15.
 */

public class StringModel extends AbstractModelPost {

    private IObjectView<String> view;

    public StringModel(IObjectView<String> view) {
        super();
        this.view = view;
    }

    @Override
    public void getData(String... args) {
        HttpManager manager = HttpManager.getInstance();
        manager.post(UrlConstants.SAN_PHONE, getParams(), lisenter(), errorListener());
    }

    @Override
    protected void error(String message) {
        view.failure(message);
    }

    @Override
    protected void success(Object result) {
        final Gson gson = new Gson();
        LogCat.i(result.toString());
//        StringResponse t = gson.fromJson(result, StringResponse.class);
//        final int status = t.getStatus();
//        final String message = t.getMessage();
//
//        if (relogin(message, t.getMessageCode())) {
//            return;
//        }
//
//        if (status == 0) {
//            view.success(t.getBody());
//        } else {
//            view.failure(message);
//        }
    }
}
